package com.authine.cloudpivot.ext.applicationservice;

import com.authine.cloudpivot.ext.dto.DemandGoodDto;
import com.authine.cloudpivot.ext.utils.JdbcUtil;
import com.authine.hermes.app.launcher.response.SingleResponse;
import com.authine.hermes.app.launcher.service.ApplicationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.authine.hermes.app.launcher.service.ApplicationServiceFoundation.CUSTOM_SERVICE;

@Slf4j
@Path("DemoApplicationService")
public class DemandGoodService extends ApplicationService {

    @Path("queryDemandGoodList")
    @POST
    @Operation(summary = "查询待执行，今日执行，待提交，全部需求，今日提交接口，返回需求商品id，作为查询参数调用listbo",tags = CUSTOM_SERVICE)
    public SingleResponse queryDemandGoodList(@Parameter DemandGoodDto demandGoodDto){
        List<String> list = new ArrayList<>();
        try{
            List<Map<String, Object>> orderList = JdbcUtil.queryDemandGoodList(demandGoodDto);
            if (orderList != null && orderList.size() > 0){

                orderList.forEach(item->{
                    list.add((String) item.get("id"));
                });
            }
            return SingleResponse.of(list);
        }catch (Exception e){
            log.info("e","查询需求商品失败！");
            return  SingleResponse.of(null);
        }

    }



}
